//
//  ViewController.m
//  UI08-KVC
//
//  Created by lanou3g on 17/8/14.
//  Copyright © 2017年 lanou3g. All rights reserved.
//

#import "ViewController.h"
#import "Song.h"

@interface ViewController ()

@property(nonatomic,retain)NSMutableArray *songArray;

@end

@implementation ViewController

-(void)getData {
    //初始化数组
    self.songArray = [NSMutableArray array];
    //加载plist文件
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"SongList" ofType:@"plist"];
    NSArray *songlist = [NSArray arrayWithContentsOfFile:filePath];
    
    //遍历数组中的元素，是字典类型的
    for (NSDictionary *songDic in songlist) {
        Song *song = [[Song alloc] init];
//        song.title = songDic[@"title"];
//        song.author = songDic[@"author"];
//        song.album_title = songDic[@"aublm_title"];
        //KVC
        [song setValuesForKeysWithDictionary:songDic];
        [self.songArray addObject:song];
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];

    [self getData];
         
}

@end
